    var count  = 15;
    var offset = 0;
    var types = 'manga';
    

    $(document).ready(function(){ 
        initParam();
        setStyle("works");
        
        if (offset == "0"){
            $("#a_head_l").hide();
        }else{
            $("#a_head_l").show();
        }
            
        $.mobile.loading('show');
        var http = "http://anibox.me/api.php?task=get_by_genre&"+getUpdateRequest()+"&offset="+offset+"&count="+count;
        $.getJSON(http, parseJson);
        
    });  
    
    function parseJson(data){     
        if (data.length == 0){
            offset = parseInt(offset) - parseInt(count);        
            window.localStorage.setItem("worOffset", offset);
            $('#a_head_r').hide();
            var http = "http://anibox.me/api.php?task=get_by_genre&"+getUpdateRequest()+"&offset="+offset+"&count="+count;
            $.getJSON(http, parseJson);
            return;
        }
        
        for (var i in data) {
            var append = 
                '<div data-role="collapsible">'+
                '<h1 class="h_style"><div class="h_style">' + data[i].title + '</div></h1>'+
                '<div data-overlay-theme="b" data-theme="b">';
            
            var style = ' color="blue"';
            
            if ( (data[i].description != null) && (data[i].description != "")  )
                append += '<p><b><font '+style+'>ОПИСАНИЕ: </font></b>' + data[i].description + '</p>';
            
            if ( (data[i].tags != null) && (data[i].tags != "") )
                append += '<p><b><font '+style+'>ТЭГИ: </font></b>' + data[i].tags + '</p>';
           
            if ( (data[i].authors != null) && (data[i].authors != "") )
                append += '<p><b><font '+style+'>АВТОР: </font></b>' + data[i].authors + '</p>';
            
            if ( (data[i].original != null) && (data[i].original != "") )
                append += '<p><b><font '+style+'>ОРИГИНАЛ: </font></b>' + data[i].original + '</p>'
                
            if ( (data[i].translators != null) && (data[i].translators != "") )    
                append += '<p><b><font '+style+'>ПЕРЕВОДЧИКИ: </font></b>' + data[i].translators + '</p>';
            
            if ( (data[i].language != null) && (data[i].language != "") )
                append += '<p><b><font '+style+'>ЯЗЫК: </font></b>' + data[i].language + '</p>';
            
            if ( (data[i].status != null) && (data[i].status != "") )
                append += '<p><b><font '+style+'>СТАТУС: </font></b>' + data[i].status + '</p>';
            
            append += 
                '<input type="button" data-theme="a" id="'+ data[i].id +'" onClick="butClick(this.id);" style="width:100%;" value="перейти"/>'+
                '</div>'+
                '</div>'+
                '</div>\n';
            
            $('#collaps').append(append);
        }
        $('#collaps').collapsibleset('refresh');
        $.mobile.loading('hide');
    }
    
    function initParam(){
    	types = getParam("types");
    	if (types == 'ranobe')
    		document.getElementById("p_head").innerHTML = 'ранобэ';
    	
        var befoPage = window.localStorage.getItem("befoPage");
        if (befoPage == "genres"){
            offset = 0
            window.localStorage.setItem("worOffset", offset);
        }else{
            offset = window.localStorage.getItem("worOffset");
        }
        
        count = getListCount();
    }
    
    //click button in coolapsible
    function butClick(id){
        goToPage("type.html?task=get_"+types+"&id="+id);
    }
    
    //in head click befo
    function updateBefo(){
        $('#a_head_r').show();
        var int = parseInt(offset) - parseInt(count);
        if (offset == 0)
            $("#a_head_l").hide();
        if(int < 0){
            return "";
        }
        else{
            $('#collaps').empty();
            offset = int;
            var http = "http://anibox.me/api.php?task=get_by_genre&"+getUpdateRequest()+"&offset="+offset+"&count="+count;
            $.mobile.loading('show');
            $.getJSON(http, parseJson);
            window.scrollTo(0, 0);
            window.localStorage.setItem("worOffset", offset);
        } 
    }
    
    //in head click next
    function updateNext(){
        $("#a_head_l").show();
        $('#collaps').empty();
        offset = parseInt(offset) + parseInt(count);
        var http = "http://anibox.me/api.php?task=get_by_genre&"+getUpdateRequest()+"&offset="+offset+"&count="+count;
        $.mobile.loading('show');
        $.getJSON(http, parseJson);
        window.scrollTo(0, 0);
        window.localStorage.setItem("worOffset", offset);
    }
    

    //swipe(carusel)
/*    $(function(){
        // Bind the swipeHandler callback function to the swipe event on div.box
        $( "#options" ).on( "swiperight", swipeRight );
        $( "#options" ).on( "swipeleft", swipeLeft );
       
        // Callback function references the event target and adds the 'swipe' class to it
        function swipeRight( event ){
            updateBefo();
        }
        
        function swipeLeft( event ){
          updateNext();
        }
        
      });*/   